package cn.fayang.ymcc.feign;

import cn.fayang.ymcc.doc.CourseDoc;
import cn.fayang.ymcc.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 熔断降级方案
 */
@Component
public class CourseSearchFeignClientFallBackFactory implements FallbackFactory<CourseSearchFeignClient> {


    @Override
    public CourseSearchFeignClient create(Throwable throwable) {
        return new CourseSearchFeignClient() {
            @Override
            public JSONResult saveCourse(CourseDoc doc) {
                return JSONResult.error("课程上架服务不可达");
            }

            @Override
            public JSONResult deleteCourse(Long id) {
                return JSONResult.error("课程下架服务不可达");
            }
        };
    }
}
